AC_CHECK_FUNCS(mallinfo)
AC_CHECK_HEADERS([sys/resource.h])
+# _NL_TIME_FIRST_WEEKDAY is an enum and not a define
+AC_MSG_CHECKING([for _NL_TIME_FIRST_WEEKDAY])
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <langinfo.h>]],
+ [[nl_langinfo(_NL_TIME_FIRST_WEEKDAY);]])],
+ [langinfo_ok=yes], [langinfo_ok=no])
+AC_MSG_RESULT($langinfo_ok)
+if test "$langinfo_ok" = "yes"; then
+ AC_DEFINE([HAVE__NL_TIME_FIRST_WEEKDAY], [1],
+ [Define if _NL_TIME_FIRST_WEEKDAY is available])
+fi
+
# Sets GLIB_GENMARSHAL and GLIB_MKENUMS
AM_PATH_GLIB_2_0()
G_IR_SCANNER=`$PKG_CONFIG --variable=g_ir_scanner gobject-introspection-1.0`
this._update(false);
}));
- // FIXME: This is actually the fallback method for GTK+ for the week start;
- // GTK+ by preference uses nl_langinfo (NL_TIME_FIRST_WEEKDAY). We probably
- // should add a C function so we can do the full handling.
- this._weekStart = NaN;
+ this._weekStart = Shell.util_get_week_start();
this._weekdate = NaN;
this._digitWidth = NaN;
this._settings = new Gio.Settings({ schema: 'org.gnome.shell.calendar' });
this._settings.connect('changed::' + SHOW_WEEKDATE_KEY, Lang.bind(this, this._onSettingsChange));
this._useWeekdate = this._settings.get_boolean(SHOW_WEEKDATE_KEY);
- let weekStartString = Gettext_gtk30.gettext('calendar:week_start:0');
- if (weekStartString.indexOf('calendar:week_start:') == 0) {
- this._weekStart = parseInt(weekStartString.substring(20));
- }
-
- if (isNaN(this._weekStart) || this._weekStart < 0 || this._weekStart > 6) {
- log('Translation of "calendar:week_start:0" in GTK+ is not correct');
- this._weekStart = 0;
- }
-
// Find the ordering for month/year in the calendar heading
this._headerFormatWithoutYear = '%B';
switch (Gettext_gtk30.gettext('calendar:MY')) {
this._eventSource.connect('changed', Lang.bind(this, this._update));
this._desktopSettings = new Gio.Settings({ schema: 'org.gnome.desktop.interface' });
this._desktopSettings.connect('changed', Lang.bind(this, this._update));
- let weekStartString = Gettext_gtk30.gettext('calendar:week_start:0');
- if (weekStartString.indexOf('calendar:week_start:') == 0) {
- this._weekStart = parseInt(weekStartString.substring(20));
- }
-
- if (isNaN(this._weekStart) ||
- this._weekStart < 0 ||
- this._weekStart > 6) {
- log('Translation of "calendar:week_start:0" in GTK+ is not correct');
- this._weekStart = 0;
- }
+ this._weekStart = Shell.util_get_week_start();
this._update();
},
#include <glib/gi18n-lib.h>
#include <gtk/gtk.h>
+#ifdef HAVE__NL_TIME_FIRST_WEEKDAY
+#include <langinfo.h>
+#endif
+
#include <libxml/parser.h>
#include <libxml/tree.h>
#include <libxml/xmlmemory.h>
return result;
}
+/**
+ * shell_util_get_week_start:
+ *
+ * Gets the first week day for the current locale, expressed as a
+ * number in the range 0..6, representing week days from Sunday to
+ * Saturday.
+ *
+ * Returns: A number representing the first week day for the current
+ * locale
+ */
+/* Copied from gtkcalendar.c */
+int
+shell_util_get_week_start ()
+{
+ int week_start;
+#ifdef HAVE__NL_TIME_FIRST_WEEKDAY
+ union { unsigned int word; char *string; } langinfo;
+ int week_1stday = 0;
+ int first_weekday = 1;
+ guint week_origin;
+#else
+ char *gtk_week_start;
+#endif
+
+#ifdef HAVE__NL_TIME_FIRST_WEEKDAY
+ langinfo.string = nl_langinfo (_NL_TIME_FIRST_WEEKDAY);
+ first_weekday = langinfo.string[0];
+ langinfo.string = nl_langinfo (_NL_TIME_WEEK_1STDAY);
+ week_origin = langinfo.word;
+ if (week_origin == 19971130) /* Sunday */
+ week_1stday = 0;
+ else if (week_origin == 19971201) /* Monday */
+ week_1stday = 1;
+ else
+ g_warning ("Unknown value of _NL_TIME_WEEK_1STDAY.\n");
+
+ week_start = (week_1stday + first_weekday - 1) % 7;
+#else
+ gtk_week_start = dgettext ("gtk30", "calendar:week_start:0");
+
+ if (strncmp (gtk_week_start, "calendar:week_start:", 20) == 0)
+ week_start = *(gtk_week_start + 20) - '0';
+ else
+ week_start = -1;
+
+ if (week_start < 0 || week_start > 6)
+ {
+ g_warning ("Whoever translated calendar:week_start:0 for GTK+ "
+ "did so wrongly.\n");
+ week_start = 0;
+ }
+#endif
+
+ return week_start;
+}
+
/**
* shell_get_event_state:
* @event: a #ClutterEvent
void shell_util_get_transformed_allocation (ClutterActor *actor,
ClutterActorBox *box);
+int shell_util_get_week_start (void);
char *shell_util_format_date (const char *format,
gint64 time_ms);